package com.teacher.controller;

import com.teacher.entity.Evaluation;
import com.teacher.service.EvaluationService;
import com.teacher.untils.ResultEntity;
import com.teacher.untils.ResultUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "评价信息管理")
@RequestMapping("/evaluation")
@RestController
public class EvaluationController {
    @Autowired
    private EvaluationService evaluationService;

    // 增加
    @ApiOperation("评价信息增加")
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public ResultEntity  addEvaluation(@RequestBody Evaluation evaluation){
        return ResultUtils.build(evaluationService.addEvaluation(evaluation));
    }

    // 修改
    @ApiOperation("评价信息修改")
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public ResultEntity updateEvaluationCriterion(@RequestBody Evaluation evaluation){
        return ResultUtils.build(evaluationService.updateEvaluation(evaluation));
    }

    // 根据id查看详情
    @ApiOperation("评价信息查看详情")
    @GetMapping(value = "/getDetailsById/{id}")
    public ResultEntity getDetailsById(@PathVariable("id") String id){
        return ResultUtils.build(evaluationService.getDetailsById(id));
    }

    // 根据id删除
    @ApiOperation("评价信息删除")
    @DeleteMapping(value = "/delete/{id}")
    public void deleteEvaluation(@PathVariable("id") String id){
        evaluationService.deleteEvaluation(id);
    }

    // 根据id批量删除
    @ApiOperation("评价信息批量删除")
    @DeleteMapping("/batch")
    public void deleteEvaluationList(String idList){
        evaluationService.deleteEvaluationList(idList);
    }

    // 根据条件分页查询
    @ApiOperation(value = "根据条件分页查询",notes = "根据条件分页查询")
    @GetMapping("/specificPage")
    public ResultEntity specificPageQueryEvaluationList(Evaluation evaluation,int page,int size){
        return ResultUtils.build(evaluationService.specificPageQueryEvaluationList(evaluation,page,size));
    }
}
